import Vue from 'vue'
import Vuex from 'vuex'

import { getUserInfo } from "../api/index"

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userInfo: {}
  },
  mutations: {
    set_user_info(state, data) {
      state.userInfo = data
    }
  },
  actions: {
    get_user_info({ commit }) {
      getUserInfo().then(res => {
        let data = {
          header_img: res.data.result.header_img,
          name: res.data.result.name,
        }
        commit('set_user_info', data)
      })
    }
  },
  modules: {
  }
})
